<template>
  <div class="dashboard-container">
    <h1>开发中....</h1>
  </div>
</template>

<script>
import { sendcode } from "@/api/user";
import { mapGetters } from "vuex";
export default {
  name: "Dashboard",
  computed: {
    ...mapGetters(["name"])
  },
  data() {
    return {
      active: 0,
      sendAuthCode: true,
      auth_time: 0,
      form: {
        username: "",
        email: "",
        password: "",
        repassword: ""
      },
      singuprules: {
        username: [
          {
            required: true,
            message: "请输入用户名",
            trigger: "blur"
          }
        ],
        password: [
          { required: true, message: "请输入用户密码", trigger: "blur" },
          {
            min: 6,
            max: 16,
            message: "长度在 6 到 16 个字符",
            trigger: "blur"
          }
        ],
        repassword: [
          { required: true, message: "请输入用户密码", trigger: "blur" },
          {
            min: 6,
            max: 16,
            message: "长度在 6 到 16 个字符",
            trigger: "blur"
          }
        ],
        email: [
          {
            required: true,
            message: "请输入邮箱地址",
            trigger: "blur"
          }
        ]
      }
    };
  },
  methods: {
    next() {
      console.log(this.active);
      if (this.active++ > 2) this.active = 0;
    },
    sign() {
      this.active = 3;
    },
    send() {
      sendcode(this.form.email).then(res => {
        if (res.code === 200) {
          this.sendAuthCode = false;
          this.auth_time = 10;
          var auth_timetimer = setInterval(() => {
            this.auth_time--;
            if (this.auth_time <= 0) {
              this.sendAuthCode = true;
              clearInterval(auth_timetimer);
            }
          }, 1000);
          this.$message({
            message: res.message,
            type: "success"
          });
        }
      });
    }
  },
  mounted() {
    console.log(this.active);
  }
};
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
